# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: customer ticketclerk concessionclerk tickettaker manager movietechnician project4 launchcustomers createmovietech createmanager createtickettakers createconcessionclerks createticketclerks createcustomers


start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s

halt.o: halt.c
	$(CC) $(CFLAGS) -c halt.c
halt: halt.o start.o
	$(LD) $(LDFLAGS) start.o halt.o -o halt.coff
	../bin/coff2noff halt.coff halt

sort.o: sort.c
	$(CC) $(CFLAGS) -c sort.c
sort: sort.o start.o
	$(LD) $(LDFLAGS) start.o sort.o -o sort.coff
	../bin/coff2noff sort.coff sort
	
bettersort.o: bettersort.c
	$(CC) $(CFLAGS) -c bettersort.c
bettersort: bettersort.o start.o
	$(LD) $(LDFLAGS) start.o bettersort.o -o bettersort.coff
	../bin/coff2noff bettersort.coff bettersort

matmult.o: matmult.c
	$(CC) $(CFLAGS) -c matmult.c
matmult: matmult.o start.o
	$(LD) $(LDFLAGS) start.o matmult.o -o matmult.coff
	../bin/coff2noff matmult.coff matmult

doublematmult.o: doublematmult.c
	$(CC) $(CFLAGS) -c doublematmult.c
doublematmult: doublematmult.o start.o
	$(LD) $(LDFLAGS) start.o doublematmult.o -o doublematmult.coff
	../bin/coff2noff doublematmult.coff doublematmult
	
triplematmult.o: triplematmult.c
	$(CC) $(CFLAGS) -c triplematmult.c
triplematmult: triplematmult.o start.o
	$(LD) $(LDFLAGS) start.o triplematmult.o -o triplematmult.coff
	../bin/coff2noff triplematmult.coff triplematmult

testfiles.o: testfiles.c
	$(CC) $(CFLAGS) -c testfiles.c
testfiles: testfiles.o start.o
	$(LD) $(LDFLAGS) start.o testfiles.o -o testfiles.coff
	../bin/coff2noff testfiles.coff testfiles
	
locktest.o: locktest.c
	$(CC) $(CFLAGS) -c locktest.c
locktest: locktest.o start.o
	$(LD) $(LDFLAGS) start.o locktest.o -o locktest.coff
	../bin/coff2noff locktest.coff locktest

printftest.o: printftest.c
	$(CC) $(CFLAGS) -c printftest.c
printftest: printftest.o start.o
	$(LD) $(LDFLAGS) start.o printftest.o -o printftest.coff
	../bin/coff2noff printftest.coff printftest
	
simpleuserprog.o: simpleuserprog.c
	$(CC) $(CFLAGS) -c simpleuserprog.c
simpleuserprog: simpleuserprog.o start.o
	$(LD) $(LDFLAGS) start.o simpleuserprog.o -o simpleuserprog.coff
	../bin/coff2noff simpleuserprog.coff simpleuserprog
	
exittest.o: exittest.c
	$(CC) $(CFLAGS) -c exittest.c
exittest: exittest.o start.o
	$(LD) $(LDFLAGS) start.o exittest.o -o exittest.coff
	../bin/coff2noff exittest.coff exittest
	
exec1test.o: exec1test.c
	$(CC) $(CFLAGS) -c exec1test.c
exec1test: exec1test.o start.o
	$(LD) $(LDFLAGS) start.o exec1test.o -o exec1test.coff
	../bin/coff2noff exec1test.coff exec1test

exec5test.o: exec5test.c
	$(CC) $(CFLAGS) -c exec5test.c
exec5test: exec5test.o start.o
	$(LD) $(LDFLAGS) start.o exec5test.o -o exec5test.coff
	../bin/coff2noff exec5test.coff exec5test

exec50test.o: exec50test.c
	$(CC) $(CFLAGS) -c exec50test.c
exec50test: exec50test.o start.o
	$(LD) $(LDFLAGS) start.o exec50test.o -o exec50test.coff
	../bin/coff2noff exec50test.coff exec50test
	
forktest.o: forktest.c
	$(CC) $(CFLAGS) -c forktest.c
forktest: forktest.o start.o
	$(LD) $(LDFLAGS) start.o forktest.o -o forktest.coff
	../bin/coff2noff forktest.coff forktest
	
fork3test.o: fork3test.c
	$(CC) $(CFLAGS) -c fork3test.c
fork3test: fork3test.o start.o
	$(LD) $(LDFLAGS) start.o fork3test.o -o fork3test.coff
	../bin/coff2noff fork3test.coff fork3test

movietheater.o: movietheater.c
	$(CC) $(CFLAGS) -c movietheater.c
movietheater: movietheater.o start.o
	$(LD) $(LDFLAGS) start.o movietheater.o -o movietheater.coff
	../bin/coff2noff movietheater.coff movietheater

singlemovietheater.o: singlemovietheater.c
	$(CC) $(CFLAGS) -c singlemovietheater.c
singlemovietheater: singlemovietheater.o start.o
	$(LD) $(LDFLAGS) start.o singlemovietheater.o -o singlemovietheater.coff
	../bin/coff2noff singlemovietheater.coff singlemovietheater
	
doublemovietheater.o: doublemovietheater.c
	$(CC) $(CFLAGS) -c doublemovietheater.c
doublemovietheater: doublemovietheater.o start.o
	$(LD) $(LDFLAGS) start.o doublemovietheater.o -o doublemovietheater.coff
	../bin/coff2noff doublemovietheater.coff doublemovietheater
	
ultimatetest.o: ultimatetest.c
	$(CC) $(CFLAGS) -c ultimatetest.c
ultimatetest: ultimatetest.o start.o
	$(LD) $(LDFLAGS) start.o ultimatetest.o -o ultimatetest.coff
	../bin/coff2noff ultimatetest.coff ultimatetest
	
signaltest.o: signaltest.c
	$(CC) $(CFLAGS) -c signaltest.c
signaltest: signaltest.o start.o
	$(LD) $(LDFLAGS) start.o signaltest.o -o signaltest.coff
	../bin/coff2noff signaltest.coff signaltest

waittest.o: waittest.c
	$(CC) $(CFLAGS) -c waittest.c
waittest: waittest.o start.o
	$(LD) $(LDFLAGS) start.o waittest.o -o waittest.coff
	../bin/coff2noff waittest.coff waittest

customer.o: customer.c
	$(CC) $(CFLAGS) -c customer.c
customer: customer.o start.o
	$(LD) $(LDFLAGS) start.o customer.o -o customer.coff
	../bin/coff2noff customer.coff customer
	
ticketclerk.o: ticketclerk.c
	$(CC) $(CFLAGS) -c ticketclerk.c
ticketclerk: ticketclerk.o start.o
	$(LD) $(LDFLAGS) start.o ticketclerk.o -o ticketclerk.coff
	../bin/coff2noff ticketclerk.coff ticketclerk
	
concessionclerk.o: concessionclerk.c
	$(CC) $(CFLAGS) -c concessionclerk.c
concessionclerk: concessionclerk.o start.o
	$(LD) $(LDFLAGS) start.o concessionclerk.o -o concessionclerk.coff
	../bin/coff2noff concessionclerk.coff concessionclerk
	
tickettaker.o: tickettaker.c
	$(CC) $(CFLAGS) -c tickettaker.c
tickettaker: tickettaker.o start.o
	$(LD) $(LDFLAGS) start.o tickettaker.o -o tickettaker.coff
	../bin/coff2noff tickettaker.coff tickettaker
	
manager.o: manager.c
	$(CC) $(CFLAGS) -c manager.c
manager: manager.o start.o
	$(LD) $(LDFLAGS) start.o manager.o -o manager.coff
	../bin/coff2noff manager.coff manager
	
movietechnician.o: movietechnician.c
	$(CC) $(CFLAGS) -c movietechnician.c
movietechnician: movietechnician.o start.o
	$(LD) $(LDFLAGS) start.o movietechnician.o -o movietechnician.coff
	../bin/coff2noff movietechnician.coff movietechnician
	
project4.o: project4.c
	$(CC) $(CFLAGS) -c project4.c
project4: project4.o start.o
	$(LD) $(LDFLAGS) start.o project4.o -o project4.coff
	../bin/coff2noff project4.coff project4
	
launchcustomers.o: launchcustomers.c
	$(CC) $(CFLAGS) -c launchcustomers.c
launchcustomers: launchcustomers.o start.o
	$(LD) $(LDFLAGS) start.o launchcustomers.o -o launchcustomers.coff
	../bin/coff2noff launchcustomers.coff launchcustomers

p4exectest.o: p4exectest.c
	$(CC) $(CFLAGS) -c p4exectest.c
p4exectest: p4exectest.o start.o
	$(LD) $(LDFLAGS) start.o p4exectest.o -o p4exectest.coff
	../bin/coff2noff p4exectest.coff p4exectest
	
createcustomers.o: createcustomers.c
	$(CC) $(CFLAGS) -c createcustomers.c
createcustomers: createcustomers.o start.o
	$(LD) $(LDFLAGS) start.o createcustomers.o -o createcustomers.coff
	../bin/coff2noff createcustomers.coff createcustomers
	
createticketclerks.o: createticketclerks.c
	$(CC) $(CFLAGS) -c createticketclerks.c
createticketclerks: createticketclerks.o start.o
	$(LD) $(LDFLAGS) start.o createticketclerks.o -o createticketclerks.coff
	../bin/coff2noff createticketclerks.coff createticketclerks
	
createconcessionclerks.o: createconcessionclerks.c
	$(CC) $(CFLAGS) -c createconcessionclerks.c
createconcessionclerks: createconcessionclerks.o start.o
	$(LD) $(LDFLAGS) start.o createconcessionclerks.o -o createconcessionclerks.coff
	../bin/coff2noff createconcessionclerks.coff createconcessionclerks
	
createtickettakers.o: createtickettakers.c
	$(CC) $(CFLAGS) -c createtickettakers.c
createtickettakers: createtickettakers.o start.o
	$(LD) $(LDFLAGS) start.o createtickettakers.o -o createtickettakers.coff
	../bin/coff2noff createtickettakers.coff createtickettakers
	
createmanager.o: createmanager.c
	$(CC) $(CFLAGS) -c createmanager.c
createmanager: createmanager.o start.o
	$(LD) $(LDFLAGS) start.o createmanager.o -o createmanager.coff
	../bin/coff2noff createmanager.coff createmanager
	
createmovietech.o: createmovietech.c
	$(CC) $(CFLAGS) -c createmovietech.c
createmovietech: createmovietech.o start.o
	$(LD) $(LDFLAGS) start.o createmovietech.o -o createmovietech.coff
	../bin/coff2noff createmovietech.coff createmovietech
	
clean:
	rm -f *.o *.coff
